package com.oa.xinxi.dao;

import com.oa.xinxi.entity.Rules;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface RulesMapper {
    @Delete({
        "delete from rules",
        "where rules_id = #{rulesId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer rulesId);

    @Insert({
        "insert into rules (rules_id, title, ",
        "creator, createtime, ",
        "updator, update_time, ",
        "rules_content)",
        "values (#{rulesId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{creator,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{updator,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{rulesContent,jdbcType=LONGVARCHAR})"
    })
    int insert(Rules record);

    @InsertProvider(type=RulesSqlProvider.class, method="insertSelective")
    int insertSelective(Rules record);

    @Select({
        "select",
        "rules_id, title, creator, createtime, updator, update_time, rules_content",
        "from rules",
        "where rules_id = #{rulesId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="rules_id", property="rulesId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="rules_content", property="rulesContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    Rules selectByPrimaryKey(Integer rulesId);

    @UpdateProvider(type=RulesSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Rules record);

    @Update({
        "update rules",
        "set title = #{title,jdbcType=VARCHAR},",
          "creator = #{creator,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updator = #{updator,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "rules_content = #{rulesContent,jdbcType=LONGVARCHAR}",
        "where rules_id = #{rulesId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Rules record);

    @Update({
        "update rules",
        "set title = #{title,jdbcType=VARCHAR},",
          "creator = #{creator,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updator = #{updator,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where rules_id = #{rulesId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Rules record);
    @Select({
        "select",
        "rules_id, title, creator, createtime, updator, update_time, rules_content",
        "from rules"
    })
    @Results({
        @Result(column="rules_id", property="rulesId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="rules_content", property="rulesContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Rules> findAll();
}